﻿/*  Francis Nino Seisei 
 *  ©2012 Francis Antonio Bolaños Arias.
 * 
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Seisei.Global
{
    public class DataTypes
    {
        public static string[,] Types = new string[6, 30] { 
                                            {"NINO" , "mssql",  "BIGINT", "BINARY", "BIT", "CHAR", "DATE", "DATETIME", "DATETIME2", "DATETIMEOFFSET", "DECIMAL", "FLOAT", "IMAGE" , "INT", "MONEY" , "NCHAR", "NTEXT" , "NVARCHAR", "REAL", "SMALLDATETIME", "SMALLINT", "SMALLMONEY", "TEXT", "TIME", "TIMESTAMP", "TINYINT", "UNIQUEINDENTIFIER", "VARBINARY", "VARCHAR", "XML"},
                                            {"LEVEL0", "", "", "", "", "", "", "", "", "", "", "", "" , "", "", "", "" , "", "", "", "", "", "", "", "", "", "", "", "", ""},
                                            {"LEVEL1", "", "", "", "", "", "", "", "", "", "", "", "" , "", "", "", "" , "", "", "", "", "", "", "", "", "", "", "", "", ""},
                                            {"LEVEL2", "", "", "", "", "", "", "", "", "", "", "", "" , "", "", "", "" , "", "", "", "", "", "", "", "", "", "", "", "", ""},
                                            {"LEVEL3", "", "", "", "", "", "", "", "", "", "", "", "" , "", "", "", "" , "", "", "", "", "", "", "", "", "", "", "", "", ""},
                                            {"LEVEL4", "", "", "", "", "", "", "", "", "", "", "", "" , "", "", "", "" , "", "", "", "", "", "", "", "", "", "", "", "", ""}
                                         };

        public static void SetDataType(int Level, string NinoDT, string DT) {
            DT = DT.Trim();
            switch (NinoDT.ToUpper())
            {
                case "SCINTILLA":
                    Types[Level, 1] = DT;
                    break;
                case "BIGINT":
                    Types[Level, 2] = DT;
                    break;
                case "BINARY":
                    Types[Level, 3] = DT;
                    break;
                case "BIT":
                    Types[Level, 4] = DT;
                    break;
                case "CHAR":
                    Types[Level, 5] = DT;
                    break;
                case "DATE":
                    Types[Level, 6] = DT;
                    break;
                case "DATETIME":
                    Types[Level, 7] = DT;
                    break;
                case "DATETIME2":
                    Types[Level, 8] = DT;
                    break;
                case "DATETIMEOFFSET":
                    Types[Level, 9] = DT;
                    break;
                case "DECIMAL":
                    Types[Level, 10] = DT;
                    break;
                case "FLOAT":
                    Types[Level, 11] = DT;
                    break;
                case "IMAGE":
                    Types[Level, 12] = DT;
                    break;
                case "INT":
                    Types[Level, 13] = DT;
                    break;
                case "MONEY":
                    Types[Level, 14] = DT;
                    break;
                case "NCHAR":
                    Types[Level, 15] = DT;
                    break;
                case "NTEXT":
                    Types[Level, 16] = DT;
                    break;
                case "NVARCHAR":
                    Types[Level, 17] = DT;
                    break;
                case "REAL":
                    Types[Level, 18] = DT;
                    break;
                case "SMALLDATETIME":
                    Types[Level, 19] = DT;
                    break;
                case "SMALLINT":
                    Types[Level, 20] = DT;
                    break;
                case "SMALLMONEY":
                    Types[Level, 21] = DT;
                    break;
                case "TEXT":
                    Types[Level, 22] = DT;
                    break;
                case "TIME":
                    Types[Level, 23] = DT;
                    break;
                case "TIMESTAMP":
                    Types[Level, 24] = DT;
                    break;
                case "TINYINT":
                    Types[Level, 25] = DT;
                    break;
                case "UNIQUEIDENTIFIER":
                    Types[Level, 26] = DT;
                    break;
                case "VARBINARY":
                    Types[Level, 27] = DT;
                    break;
                case "VARCHAR":
                    Types[Level, 28] = DT;
                    break;
                case "XML":
                    Types[Level, 29] = DT;
                    break;
            }
        }

        public static string GetDataType(int Level, string NinoDT)
        {
            string DT = NinoDT;
            switch (NinoDT.ToUpper())
            {
                case "SCINTILLA":
                    DT = Types[Level, 1];
                    break;
                case "BIGINT":
                    DT = Types[Level, 2];
                    break;
                case "BINARY":
                    DT = Types[Level, 3];
                    break;
                case "BIT":
                    DT = Types[Level, 4];
                    break;
                case "CHAR":
                    DT = Types[Level, 5];
                    break;
                case "DATE":
                    DT = Types[Level, 6];
                    break;
                case "DATETIME":
                    DT = Types[Level, 7];
                    break;
                case "DATETIME2":
                    DT = Types[Level, 8];
                    break;
                case "DATETIMEOFFSET":
                    DT = Types[Level, 9];
                    break;
                case "DECIMAL":
                    DT = Types[Level, 10];
                    break;
                case "FLOAT":
                    DT = Types[Level, 11];
                    break;
                case "IMAGE":
                    DT = Types[Level, 12];
                    break;
                case "INT":
                    DT = Types[Level, 13];
                    break;
                case "MONEY":
                    DT = Types[Level, 14];
                    break;
                case "NCHAR":
                    DT = Types[Level, 15];
                    break;
                case "NTEXT":
                    DT = Types[Level, 16];
                    break;
                case "NVARCHAR":
                    DT = Types[Level, 17];
                    break;
                case "REAL":
                    DT = Types[Level, 18];
                    break;
                case "SMALLDATETIME":
                    DT = Types[Level, 19];
                    break;
                case "SMALLINT":
                    DT = Types[Level, 20];
                    break;
                case "SMALLMONEY":
                    DT = Types[Level, 21];
                    break;
                case "TEXT":
                    DT = Types[Level, 22];
                    break;
                case "TIME":
                    DT = Types[Level, 23];
                    break;
                case "TIMESTAMP":
                    DT = Types[Level, 24];
                    break;
                case "TINYINT":
                    DT = Types[Level, 25];
                    break;
                case "UNIQUEIDENTIFIER":
                    DT = Types[Level, 26];
                    break;
                case "VARBINARY":
                    DT = Types[Level, 27];
                    break;
                case "VARCHAR":
                    DT = Types[Level, 28];
                    break;
                case "XML":
                    DT = Types[Level, 29];
                    break;
            }
            return DT;
        }

        public static int GetDataTypeNumber(string NinoDT)
        {
            switch (NinoDT.ToUpper())
            {
                case "SCINTILLA":
                    return 1;
                case "BIGINT":
                    return 2;
                case "BINARY":
                    return 3;
                case "BIT":
                    return 4;
                case "CHAR":
                    return 5;
                case "DATE":
                    return 6;
                case "DATETIME":
                    return 7;
                case "DATETIME2":
                    return 8;
                case "DATETIMEOFFSET":
                    return 9;
                case "DECIMAL":
                    return 10;
                case "FLOAT":
                    return 11;
                case "IMAGE":
                    return 12;
                case "INT":
                    return 13;
                case "MONEY":
                    return 14;
                case "NCHAR":
                    return 15;
                case "NTEXT":
                    return 16;
                case "NVARCHAR":
                    return 17;
                case "REAL":
                    return 18;
                case "SMALLDATETIME":
                    return 19;
                case "SMALLINT":
                    return 20;
                case "SMALLMONEY":
                    return 21;
                case "TEXT":
                    return 22;
                case "TIME":
                    return 23;
                case "TIMESTAMP":
                    return 24;
                case "TINYINT":
                    return 25;
                case "UNIQUEIDENTIFIER":
                    return 26;
                case "VARBINARY":
                    return 27;
                case "VARCHAR":
                    return 28;
                case "XML":
                    return 29;
            }
            return 0;
        }

        public static string GetDataTypeWithNumber(int Level, int DataTypeNumber)
        {
            return Types[Level, DataTypeNumber];
        }
    }
}
